# -*- coding:utf8 -*-

from PyQt4.QtCore import *
from PyQt4.QtGui import *
from tableHuman import tableHuman
import sys
from addWind import * 


class MainWindow(QMainWindow):
    def __init__(self, parent=None):
        super(MainWindow, self).__init__(parent)

        self.setWindowTitle('SM3DE')
        self.table = tableHuman()
        
        self.zoneCentrale = QWidget()
        self.centralLayout = QHBoxLayout()
        self.zoneCentrale.setLayout(self.centralLayout)

        self.buttonLayout = QVBoxLayout()
        self.tableLayout = QVBoxLayout()
        self.tableLayout.addWidget(self.table)

        self.buttonAdd = QPushButton('Ajouter')
        self.connect(self.buttonAdd, SIGNAL("clicked()"), self.showAddWindow)
        self.buttonLayout.addWidget(self.buttonAdd)

        self.buttonRandom = QPushButton('Tirage aléatoire'.decode("utf-8"))
        self.connect(self.buttonRandom, SIGNAL("clicked()"), self.randomPop)
        self.buttonLayout.addWidget(self.buttonRandom)

        self.buttonPref = QPushButton('Préférences'.decode("utf-8"))
        self.connect(self.buttonPref, SIGNAL("clicked()"), self.showPrefWindow)
        self.buttonLayout.addWidget(self.buttonPref)

        self.buttonNext = QPushButton('Prochaine génération'.decode("utf-8"))
        self.connect(self.buttonNext, SIGNAL("clicked()"), self.nextIter)
        self.buttonLayout.addWidget(self.buttonNext)

        self.buttonQuit = QPushButton('Quitter')
        self.connect(self.buttonQuit, SIGNAL("clicked()"), qApp, SLOT("quit()"))
        self.buttonLayout.addWidget(self.buttonQuit)

        self.buttonLayout.addStretch()

        self.centralLayout.addLayout(self.buttonLayout)
        self.centralLayout.addWidget(self.table)

        self.statusBar = QStatusBar()
        self.statusBarLabel = QLabel()
        self.updateStatusBar()
        self.statusBar.setStyleSheet("QStatusBar::item { border: 0px solid black }; ")
        self.statusBar.addWidget(self.statusBarLabel, 1)
        self.setStatusBar(self.statusBar)

        self.setCentralWidget(self.zoneCentrale)

    def updateStatusBar(self):
        self.statusBarLabel.setText('Score moyen : ' + str() + ' / Score maximum : ' + str())

    def showAddWindow(self):
        
        self.ajouter = AddWind()
        self.ajouter.show()
        
        print "showAddWindow"

    def showPrefWindow(self):
        print "showPrefWindow"

    def randomPop(self):
        print "RandomPop"

    def nextIter(self):
        print "nextIter"
        

        
        
